'use strict';

const BaseController = require('../sys/base');
const qiniu = require('../../utils/qiniu');
const await = require('await-stream-ready/lib/await');

/**
 * 单位管理
 */
class unitController extends BaseController {

  // 添加活动
  async add() {
    const { ctx } = this;
    let postData = ctx.request.body;
    let result = await ctx.service.organization.unit.add(postData);
    this.success(result);
  }

  // 获取活动列表
  async list() {
    const { ctx } = this;
    let result = await ctx.service.organization.unit.list(ctx.request.query);
    this.success(result);
  }

  // 更新单位
  async update() {
    const { ctx } = this;
    const requestData = ctx.request.body;
    let result = await ctx.service.organization.unit.update(requestData);
    this.success(result);
  }

  // 删除单位
  async delete() {
    const { ctx } = this;
    const requestData = ctx.request.query;
    const result = await ctx.service.organization.unit.delete(requestData);
    this.success(result);
  }
}

module.exports = unitController;
